function mymove() {

    var dv = $('.o_technical_modal > div > div.modal-content');
    var header = $('.o_technical_modal > div > div.modal-content >header.modal-header');
    var x = 0;
    var y = 0;
    var l = 0;
    var t = 0;
    var isDown = false;

    header.mousedown(function(e) {
        x = e.clientX;
        y = e.clientY;

        l = dv.offset().left
        t = dv.offset().top;
        isDown = true;
        header.css('cursor','move')
    })

    window.onmousemove = function(e) {
        if (isDown == false) {
            return;
        }
        var nx = e.clientX;
        var ny = e.clientY;
        var nl = nx - (x - l);
        var nt = ny - (y - t);

        dv.offset({top:nt,left:nl})
    }
    header.mouseup(function() {
        isDown = false;
        header.css('cursor','auto')
    })
}

$(document).ready(function(){
    var is_Inserted = false
    $("body").bind('DOMNodeInserted', function(e) {
        if($('.o_technical_modal > div > div.modal-content').length>0){
            $('.o_technical_modal > div > div.modal-content >header.modal-header').css({'background-color':'#7C7BAD'})
            if(!is_Inserted){
                mymove()
                is_Inserted = true
            }
        }
    });
    $("body").bind('DOMNodeRemoved', function(e) {
        if($('.o_technical_modal > div > div.modal-content').length===0){
            is_Inserted = false
        }
    });
});

odoo.define("sys_tools.web_dialog_move_size", function(require) {
    "use strict";

    var Dialog = require("web.Dialog");

    Dialog.include({
        willStart: function() {
            var self = this;
            return this._super.apply(this, arguments).then(function() {
                self.$modal
                    .find(".dialog_button_extend")
                    .on("click", self.proxy("_extending"));
                self.$modal
                    .find(".dialog_button_restore")
                    .on("click", self.proxy("_restore"));
                self._restore();
            });
        },

        _extending: function() {
            debugger;
            var dialog = this.$modal.find(".modal-dialog");
            dialog.addClass("dialog_full_screen");
            dialog.find(".dialog_button_extend").hide();
            dialog.find(".dialog_button_restore").show();
        },

        _restore: function() {
            var dialog = this.$modal.find(".modal-dialog");
            dialog.removeClass("dialog_full_screen");
            dialog.find(".dialog_button_restore").hide();
            dialog.find(".dialog_button_extend").show();
        },
    });

});
